Dim nsInstance, nsApplication, nsSubscriber, nsSubscriberDevice

Set nsInstance = WScript.CreateObject("Microsoft.SqlServer.NotificationServices.NSInstance")
nsInstance.Initialize "OrderEntry"

Set nsApplication = WScript.CreateObject("Microsoft.SqlServer.NotificationServices.NSApplication")
nsApplication.Initialize(nsInstance), "NSApplication"

Set nsSubscriberDevice = WScript.CreateObject("Microsoft.SqlServer.NotificationServices.SubscriberDevice")
nsSubscriberDevice.Initialize(nsInstance)
nsSubscriberDevice.DeviceTypeName      = "SMTP"
nsSubscriberDevice.DeviceName          = "myEmailDevice"
nsSubscriberDevice.DeliveryChannelName = "EmailChannel"

nsSubscriberDevice.SubscriberId        = "CompDept_Delivery"
nsSubscriberDevice.DeviceAddress       = "agnaldo@50minutos.com.br"
nsSubscriberDevice.Add

nsSubscriberDevice.SubscriberId        = "BooksDept_Errors"
nsSubscriberDevice.DeviceAddress       = "agnaldo@50minutos.com.br"
nsSubscriberDevice.Add

Set nsSubscription = WScript.CreateObject("Microsoft.SqlServer.NotificationServices.Subscription")
nsSubscription.Initialize(nsApplication), "OrdersS"
nsSubscription.SetFieldValue "DeviceName", "myEmailDevice"
nsSubscription.SetFieldValue "SubscriberLocale", "en-us"

nsSubscription.SubscriberId = "CompDept_Delivery"
nsSubscription.SetFieldValue "PaymentStatus", "S"
nsSubscription.SetFieldValue "Department", "CMP"
nsSubscription.Add

nsSubscription.SubscriberId = "BooksDept_Errors"
nsSubscription.SetFieldValue "PaymentStatus", "E"
nsSubscription.SetFieldValue "Department", "BKS"
nsSubscription.Add

